import component from './index.vue'
import { createApp, h } from 'vue'

let instance = null
let dialogCom = null
const initInstance = () => {
  if (instance) return instance
  const container = document.createElement('div')
  document.body.appendChild(container)
  instance = createApp({
    render() {
      return h(component, {
        ref: (el) => {
          dialogCom = el
        },
      })
    },
  })
  instance.mount(container)
  return instance
}

export const createEnterprise = (...args) => {
  initInstance()
  return dialogCom.open(...args)
}
